/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-20 21:24:10
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-22 11:19:24
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/components/animation_text.dart';
import 'package:flutter_data_center/controller/grade_attendance_controller.dart';
import 'package:flutter_data_center/utills/color_utils.dart';
import 'package:get/get.dart';

class GradeCountCard extends StatelessWidget {
  const GradeCountCard({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) => GetBuilder<GradeAttendanceController>(
        builder: (_controller) => Container(
          height: 120,
          width: double.infinity,
          padding: EdgeInsets.all(15),
          decoration: BoxDecoration(
            color: gColor("#F5F7F9"),
            borderRadius: BorderRadius.circular(10),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      "到校人数",
                      style: TextStyle(
                        fontSize: 12,
                        color: gColor("#C5C5C5"),
                      ),
                    ),
                    SizedBox(height: 5),
                    AnimText(
                      number: _controller.total,
                      style: TextStyle(
                        fontSize: 24,
                        color: Colors.black,
                        fontWeight: FontWeight.w700,
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  buildItemConnt(_controller.late, "迟到"),
                  buildItemConnt(_controller.missing, "缺卡"),
                  buildItemConnt(_controller.leave, "早退"),
                ],
              ),
            ],
          ),
        ),
      );
  Flexible buildItemConnt(int count, String label) {
    return Flexible(
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Text(
            label,
            style: TextStyle(
              fontSize: 12,
              color: Colors.black,
            ),
          ),
          SizedBox(height: 13),
          AnimText(
            number: count,
            style: TextStyle(
              fontSize: 18,
              color: gColor("#08D187"),
              fontWeight: FontWeight.w700,
            ),
          ),
        ],
      ),
    );
  }
}
